#!/usr/bin/python
# -*- coding: utf-8 -*-

##
 # Copyright 2009 Caio Souza
 # This file is part of Rpyg.
 #
 # Rpyg is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # Rpyg is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with Rpyg. If not, see <http://www.gnu.org/licenses/>.
 ##

'''Módulo de uma dungeon do jogo'''

from rpyg.Screen import Screen

class Dungeon:
    '''
    Classe que abstrai um dungeon, contem os mapas e os personagens
    do jogo.
    '''
    
    def __init__(self, tilemap, charlist):
        '''
        Cria uma nova dungeon a partir do mapa de tiles e da
        lista de jogadores.
        '''
        
        self._tilemap = tilemap
        self._charlist = charlist
        
        for char in self._charlist:
            char.setTileMap(self._tilemap)
        
    def update (self):
        '''Atualiza a tela com as imagens da dungeon.'''
        self._tilemap.updateBottom()
        
        self._charlist.sort()
        for char in self._charlist: char.update()
        
        self._tilemap.updateTop()
        Screen.update()
        